<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <!--{include file='comm/header.tpl'}-->
    <title>发布资源位</title>
</head>
<body>
<div style="width:100%">

    <!--{if $error_msg}-->

    <div class="error-box"><!--{$error_msg}-->.</div>

    <!--{else}-->

    <table id="flex1" style="display:none"></table>
    <table id="flex2" style="display:none"></table> 

    <!--{/if}-->

    <!--{include file='comm/footer.tpl'}-->

</div>

<script type="text/javascript">

    var source = {

        category_id: <!--{$category_id|default:0}-->,
        parent_id: <!--{$parent_id|default:0}-->,

        load: function(flg) {
            $("#flex" + flg).flexReload();
        },

        publish: function(source_id) {
            this.source_id = source_id;
            E.confirm("您确认要发布资源位吗？", "source.publishConfirm");
        },

        publishConfirm: function() {
            $.ajax({
                type: "GET",
                url: "/invokingAjax-backend/content/source.ajax?operFlg=8&source_id=" + source.source_id,
                dataType: "JSON",
                success: function( result_obj ) {
                    if (result_obj.code == 200) {
                        source.load(1);
                        source.load(2);
                        E.alert(result_obj.message, 2);
                    } else {
                        source.load(2);
                        E.alert(result_obj.message);
                    }
                }
            });
        },

        cancelPublish: function(source_id) {
            this.source_id = source_id;
            E.confirm("您确认要取消已发布的资源位吗？", "source.cancelPublishConfirm");
        },

        cancelPublishConfirm: function() {
            $.ajax({
                type: "GET",
                url: "/invokingAjax-backend/content/source.ajax?operFlg=9&source_id=" + source.source_id + "&parent_id=" + source.parent_id + "&category_id=" + source.category_id,
                dataType: "JSON",
                success: function( result_obj ) {
                    if (result_obj.code == 200) {
                        source.load(1);
                        source.load(2);
                        E.alert(result_obj.message, 2);
                    } else {
                        source.load(1);
                        E.alert(result_obj.message);
                    }
                }
            });
        }

    };

    $("#flex1").flexigrid({
        url:"/invokingAjax-backend/content/source.ajax?operFlg=7&parent_id=" + source.parent_id + "&category_id=" + source.category_id,
        dataType: "json",
        colModel : [
            {display: "操作", width : 80, align: "center"},
            {display: "资源位号", name : "source_id", width : 80, sortable : true},
            {display: "资源位标题", width : 200},
            {display: "资源位分类", width : 150},
            {display: "资源位简述", width : 200}
        ],
        sortname: "displayOrder",
        sortorder: "desc",
        usepager: false,
        rp: 50,
        useRp: true,
        showTableToggleBtn: true,
        autoload: source.category_id == 0 ? false : true,
        height: 150,
        title: "已发布的资源位"
    });

    $("#flex2").flexigrid({
        url:"/invokingAjax-backend/content/source.ajax?operFlg=5&publishFlg=0&parent_id=" + source.parent_id + "_" + source.category_id,
        dataType: "json",
        colModel : [
            {display: "操作", width : 80, align: "center"},
            {display: "资源位号", name : "source_id", width : 80, sortable : true},
            {display: "资源位标题", width : 200},
            {display: "资源位分类", width : 150},
            {display: "资源位简述", width : 200},
            {display: "使用标志", width : 70, align: "center"}
        ],
        sortname: "source_id",
        sortorder: "desc",
        usepager: true,
        rp: 10,
        useRp: true,
        showTableToggleBtn: true,
        autoload: source.category_id == 0 ? false : true,
        title: "未已发布的资源位"
    });



</script>

</body>

</html>
